package com.example.server.util;

import com.alibaba.fastjson.JSONObject;

import java.io.InputStream;

import static io.restassured.RestAssured.given;
import static io.restassured.matcher.RestAssuredMatchers.*;
import static org.hamcrest.Matchers.*;
import com.alibaba.fastjson.JSON;

public class RestAssuredUtil {
	public void testGetHtml(){
		given().get("http://175.27.228.178:3434/api/private/v1/login").then().log().all().statusCode(200);
	}

	public String getResponse(){
		// InputStream stream = given().get("/lotto").asInputStream();
		String json = given().get("https://4bfb4f19-f170-429e-ba79-1e04780b1891.mock.pstmn.io/abc").asString();
		System.out.println(json);
		return json;
	}

	public static void main(String[] args) {
		RestAssuredUtil restAssuredUtil = new RestAssuredUtil();
		String response = restAssuredUtil.getResponse();
		JSONObject responseJson = JSON.parseObject(response);
		String s = AnalyzeJsonUtil.getValueByJPath(responseJson,"data[*]/name");
		System.out.println(s);
	}
}
